/*
 * Copyright 2011 OpenWAF.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.openwaf.client.core;
import com.openwaf.common.annotation.*;

public class JSArray<T>  {

    @NoJavaScript
    public native JSArray<T> concate(JSArray<T> a1);

    /**
     * Joins all element by separator. In javascript separator is optional.
     * @param seperator
     * @return
     */
    @NoJavaScript
    public native String join(String seperator);
    /**
     * Remove last element of array and return it.
     * @return Last element which is removed/popped from array.
     */
    @NoJavaScript
    public native T pop();

    @NoJavaScript
    public native int push(T element);

    /**
     * Reverse the array elements .This method modifies the original array.
     * @return
     */
    @NoJavaScript
    public native JSArray<T> reverse();

    @NoJavaScript
    public native T shift();

    @NoJavaScript
    public native JSArray<T> slice(int start,int end);

    /**
     * for time being sort without any argument.
     * @return
     */
    @NoJavaScript
    public native JSArray<T> sort();
    
    /**
     *
     * @param start
     * @param end
     * @param elements
     * @return
     */
    @NoJavaScript
    public native JSArray<T> splice(int start,int end,T... elements);

    @NoJavaScript    
    public native String toString();

   
    /**
     * This method is not supported in IE according to W3Schools TODO
     * @param elements
     * @return
     */
    @NoJavaScript
    public native int unshift(T... elements);


    /**
     *
     * @return
     */
    @NoJavaScript
    public native String valueOf();

    //TODO:add aditional method here
    /**
     *
     * @return
     */
    public native int getLength()/*-{
           return this.length;
    }-*/;

    /**
     *
     * @param len
     */
    public native void setLength(int len)/*-{
         this.length=len;
    }-*/;

    //TODO:more to come
}



